<template>
  <div>hello vue3.0</div>
  <h1>{{count}}</h1>
  <h1>{{val}}</h1>
  <button @click="btn(1)">点击加一</button>
  <button @click="btn(-1)">点击减一</button>
  <h3>{{aa}}</h3>
</template>

<script>
const niuniu = ()=>{
   const count = ref(0);
  const btn  = (number) =>{
    count.value += number;
  }
  return { count,btn}
}
import { ref } from 'vue'
export default {
  name: 'App',
  // 组合式写法
  setup(){
  //代码都写在一个地方，封装服用方便
  // 获取count ,并初始化值为0
  return {aa:1111,...niuniu()}
  }
}
</script>
